home *** CD-ROM | disk | FTP | other *** search
- // LF2 Engine
- // (C) 2002-3 7FX
- //---------------------------------------------------------------------------
- #include "common.fxh"
- //---------------------------------------------------------------------------
- // Common parameters
- // Desc
- string desc : Description = "Mapuje difuzni texturu a lighmap texturu na mesh.";
- // Requirements
- string req : Requirements = "Diffusemap, lightmap";
- // vertex format
- string vf : VertexFormat = "POSITION | DIFFUSEMAP | LIGHTMAP"; // 321 (for export)
- //---------------------------------------------------------------------------
- // Used constants
- const matrix cMtxWVP : WorldViewProjection;
- const int cAlphaRef : AlphaRef = 0;
- // Diffuse color, default white
- const float4 cDiffuse : Diffuse = {1.f, 1.f, 1.f, 1.f};
- // CullMode - NONE=1, CW=2, CCW=3
- const int cCullMode : CullMode = 3; // default CCW
- // Matrices for fixed function technique
- const matrix cMtxW : World;
- // Sampler filters
- DECLARE_TEX_SAMPLER_VALUES;
- //---------------------------------------------------------------------------
- // Diffuse map texture
- texture2D diffusemap : DiffuseMap;
- // Light map texture
- texture2D lightmap : LightMap;
- //---------------------------------------------------------------------------
- // Diffuse map sampler
- sampler diffusemap_sampler = sampler_state
- {
- Texture = <diffusemap>;
- SET_TEX_SAMPLER_VALUES;
- };
- // Light map sampler
- sampler lightmap_sampler = sampler_state
- {
- Texture = <lightmap>;
- //SET_TEX_SAMPLER_FILTERS;
- MipFilter = NONE;
- MinFilter = <cMinFlt>;
- MagFilter = <cMagFlt>;
- AddressU = CLAMP;
- AddressV = CLAMP;
- };
- //---------------------------------------------------------------------------
- // programs
- struct VS_OUTPUT
- {
- float4 Position : POSITION;
- float2 DiffuseMapCoord : TEXCOORD0;
- float2 LightMapCoord : TEXCOORD1;
- };
-
- // vertex shader
- VS_OUTPUT VS(float4 Position : POSITION, float2 DiffuseMapCoord : TEXCOORD0, float2 LightMapCoord : TEXCOORD1)
- {
- VS_OUTPUT Out = (VS_OUTPUT)0;
- Out.Position = mul(Position, cMtxWVP);
- Out.DiffuseMapCoord = DiffuseMapCoord;
- Out.LightMapCoord = LightMapCoord;
- return Out;
- }
-
- // pixel shader
- float4 PS(VS_OUTPUT In) : COLOR
- {
- return cDiffuse * tex2D(diffusemap_sampler, In.DiffuseMapCoord) * tex2D(lightmap_sampler, In.LightMapCoord);
- }
-
- //---------------------------------------------------------------------------
- // Technique with vertex and pixel shader
- technique vs11_ps11
- <
- // streams for technique
- string stream1 = "POSITION | DIFFUSEMAP | LIGHTMAP";
- >
- {
- pass p0
- <
- // stream mapping
- string streammap = "stream1";
- >
- {
- AlphaRef = <cAlphaRef>;
- CullMode = <cCullMode>;
-
- VertexShader = compile vs_1_1 VS();
- PixelShader = compile ps_1_1 PS();
- }
- }
- //---------------------------------------------------------------------------
- // Basic technique - vertex shader, no pixel shader
- technique vs11_ps0
- <
- // streams for technique
- string stream1 = "POSITION | DIFFUSEMAP | LIGHTMAP";
- >
- {
- pass p0
- <
- // stream mapping
- string streammap = "stream1";
- >
- {
- AlphaRef = <cAlphaRef>;
- CullMode = <cCullMode>;
- TextureFactor = <cDiffuse>;
-
- VertexShader = compile vs_1_1 VS();
-
- // simple multitexture
- Sampler[0] = <diffusemap_sampler>;
- Sampler[1] = <lightmap_sampler>;
- ColorOp[0] = Modulate;
- ColorArg1[0] = TFactor;
- ColorArg2[0] = Texture;
- AlphaOp[0] = Modulate;
- AlphaArg2[0] = TFactor;
- AlphaArg2[0] = Texture;
- ColorOp[1] = Modulate;
- ColorArg1[1] = Current;
- ColorArg2[1] = Texture;
- AlphaOp[1] = Modulate;
- AlphaArg1[1] = Current;
- AlphaArg2[1] = Texture;
- }
- }
- //---------------------------------------------------------------------------
- // Basic technique - fixed function
- technique vs0_ps0
- <
- // streams for technique
- string stream1 = "POSITION | DIFFUSEMAP | LIGHTMAP";
- //string stream1 = "POSITION | LIGHTMAP";
- >
- {
- pass p0
- <
- // stream mapping
- string streammap = "stream1";
- >
- {
- // matrices
- WorldTransform[0] = <cMtxW>;
-
- AlphaRef = <cAlphaRef>;
- CullMode = <cCullMode>;
- TextureFactor = <cDiffuse>;
-
- // simple multitexture
- Sampler[0] = <diffusemap_sampler>;
- Sampler[1] = <lightmap_sampler>;
- ColorOp[0] = Modulate;
- ColorArg1[0] = TFactor;
- ColorArg2[0] = Texture;
- AlphaOp[0] = Modulate;
- AlphaArg2[0] = TFactor;
- AlphaArg2[0] = Texture;
- ColorOp[1] = Modulate;
- ColorArg1[1] = Current;
- ColorArg2[1] = Texture;
- AlphaOp[1] = Modulate;
- AlphaArg1[1] = Current;
- AlphaArg2[1] = Texture;
- }
- }
- //---------------------------------------------------------------------------
- // Basic technique - fixed function multipass - noteboooooks
- technique vs0_ps0mp
- <
- // streams for technique
- string stream1 = "POSITION | DIFFUSEMAP | LIGHTMAP";
- >
- {
- pass p0
- <
- // stream mapping
- string streammap = "stream1";
- >
- {
- // matrices
- WorldTransform[0] = <cMtxW>;
-
- AlphaRef = <cAlphaRef>;
- CullMode = <cCullMode>;
- TextureFactor = <cDiffuse>;
-
- Sampler[0] = <diffusemap_sampler>;
- ColorOp[0] = Modulate;
- ColorArg1[0] = TFactor;
- ColorArg2[0] = Texture;
- AlphaOp[0] = Modulate;
- AlphaArg1[0] = TFactor;
- AlphaArg2[0] = Texture;
- }
-
- pass p1
- <
- // stream mapping
- string streammap = "stream1";
- >
- {
- // matrices
- WorldTransform[0] = <cMtxW>;
-
- AlphaBlendEnable = true;
- SrcBlend = DESTCOLOR;
- DestBlend = ZERO;
-
- ZWriteEnable = false;
- //ZFunc = EQUAL;
-
- // lighmap coordinates are second!
- TexCoordIndex[0] = 1;
-
- Sampler[0] = <lightmap_sampler>;
- }
- }
- //---------------------------------------------------------------------------
-
-